package thread;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 苏西西
 * Date: 2023-09-01
 * Time: 14:59
 */
class SingletonLazy{
    private volatile static SingletonLazy instance = null;

    public static  SingletonLazy getInstance(){
       if(instance == null){
           synchronized (SingletonLazy.class) {
               if(instance == null){
                   instance = new SingletonLazy();
               }
           }

       }
        return instance;
    }
    private SingletonLazy(){

    }
}
public class ThreadDemo20 {
    public static void main(String[] args) {
        SingletonLazy s = SingletonLazy.getInstance();
        SingletonLazy s1 = SingletonLazy.getInstance();
        System.out.println(s == s1);
    }

}
